package com.xz.xzutils.module.xzmybatislogplus.socket;

/**
 * <p>
 * 心跳配置对 client 端生效
 * </p>
 *
 * @author DONG.WANG17@HAND-CHINA.COM
 * @since 2025/3/22-03-22 16:07
 */
public class SocketConfig {
    private final int port;
    private String host = "localhost";
    /**
     * 心跳消息
     */
    private String heartbeatTag = "HEARTBEAT";
    /**
     * 是否接收心跳消息
     */
    private Boolean receiveHeartbeatTag = true;
    /**
     * 心跳周期，单位毫秒
     */
    private Integer heartbeatPeriod = 10 * 1000;
    /**
     * 心跳初始化延迟，单位毫秒
     * 设置不合理可能导致心跳线程和消息发送线程冲突
     */
    private Integer heartbeatInitialDelay = 2 * 1000;
    /**
     * 重连周期，单位毫秒
     */
    private Integer reconnectPeriod = 5 * 1000;
    /**
     * 是否重连
     */
    private Boolean reconnect = true;
    /**
     * 重连最大次数
     */
    private Integer reconnectMaxNum = 5;
    private SocketCallback callback;

    public SocketConfig(int port) {
        this.port = port;
    }

    public SocketConfig(String host, int port) {
        this.host = host;
        this.port = port;
    }

    // Getters and setters
    public int getPort() {
        return port;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getHeartbeatTag() {
        return heartbeatTag;
    }

    public void setHeartbeatTag(String heartbeatTag) {
        this.heartbeatTag = heartbeatTag;
    }

    public Boolean getReceiveHeartbeatTag() {
        return receiveHeartbeatTag;
    }

    public void setReceiveHeartbeatTag(Boolean receiveHeartbeatTag) {
        this.receiveHeartbeatTag = receiveHeartbeatTag;
    }

    public int getHeartbeatPeriod() {
        return heartbeatPeriod;
    }

    public void setHeartbeatPeriod(int heartbeatPeriod) {
        this.heartbeatPeriod = heartbeatPeriod;
    }

    public int getHeartbeatInitialDelay() {
        return heartbeatInitialDelay;
    }

    public void setHeartbeatInitialDelay(int heartbeatInitialDelay) {
        this.heartbeatInitialDelay = heartbeatInitialDelay;
    }

    public void setHeartbeatPeriod(Integer heartbeatPeriod) {
        this.heartbeatPeriod = heartbeatPeriod;
    }

    public void setHeartbeatInitialDelay(Integer heartbeatInitialDelay) {
        this.heartbeatInitialDelay = heartbeatInitialDelay;
    }

    public Integer getReconnectPeriod() {
        return reconnectPeriod;
    }

    public void setReconnectPeriod(Integer reconnectPeriod) {
        this.reconnectPeriod = reconnectPeriod;
    }

    public Boolean getReconnect() {
        return reconnect;
    }

    public void setReconnect(Boolean reconnect) {
        this.reconnect = reconnect;
    }

    public Integer getReconnectMaxNum() {
        return reconnectMaxNum;
    }

    public void setReconnectMaxNum(Integer reconnectMaxNum) {
        this.reconnectMaxNum = reconnectMaxNum;
    }

    public SocketCallback getCallback() {
        return callback;
    }

    public void setCallback(SocketCallback callback) {
        this.callback = callback;
    }
}